//
//  CouponTableViewController.swift
//  ShopIOS
//
//  Created by Apple on 2019/7/26.
//  Copyright © 2019 Apple. All rights reserved.
//

import UIKit

class CouponTableViewController: UITableViewController,EmptyViewProtocol {
    var showEmtpy: Bool{
        get {
            return dataSouce.count == 0
        }
    }
    var label:UILabel?
    
    var pageNo:Int=1
    var dataSouce=[UserCoupon]()
    override func viewDidLoad() {
        super.viewDidLoad()

        
        tableView.register(UINib(nibName: "UserCouponTableViewCell", bundle: nil), forCellReuseIdentifier: "reuseIdentifier")
        tableView.separatorStyle = .none
        tableView.contentInset=UIEdgeInsets(top: 10, left: 0, bottom: 10, right: 0)
        tableView.setEmtpyViewDelegate(target: self)
        tableView.backgroundColor = "#f2f2f2".color()
        
    }
    init(dataSouce:[UserCoupon]){
        super.init(style: UITableView.Style.plain)
        self.dataSouce=dataSouce
        tableView.reloadData()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        // #warning Incomplete implementation, return the number of rows
        return dataSouce.count
    }

    
    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "reuseIdentifier", for: indexPath) as! UserCouponTableViewCell
        let item=dataSouce[indexPath.row]
        cell.lb_value.text="￥\(item.Price)"
        cell.lb_how.text=item.CouponName
        cell.lb_shopname.text=item.ShopName
        cell.lb_date.text="使用期限至：\(item.EndTime ?? "")"
        cell.selectionStyle = .none
        return cell
    }
    
    func configEmptyView() -> UIView? {
        let view=Bundle.main.loadNibNamed("NoOrderView", owner: nil, options: nil)?[0]as?UIView
        view?.height=screenH-90-kStatusBarHeight
        view?.width=screenW
        return view
    }
    

}
